package com.frxuexi.report

import com.frxuexi.lib_base.BaseViewModel
import com.frxuexi.lib_base.entity.ApiResponse
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

@HiltViewModel
class ReportViewModel @Inject constructor(private val reportRepository: ReportRepository):BaseViewModel<ReportIntent>() {
    override fun handleIntent(it: ReportIntent) {
        when(it){
            is ReportIntent.getReports->{
                httpRequest(reportRepository.getReports(it.map) as Flow<ApiResponse<Any>>)
            }
            is ReportIntent.addReport->{
                httpRequest(reportRepository.addReport(it.map))
            }
        }
    }
}